
/* this will generate bivariate gaussian distributions, for various kinds of shot pattern, and other 2d densities */

import "math/rand"

type vector2 { 
	x float64
	y float64
}

type matrix2 {
	mxx,mxy,myx,myy float64
}

function Bivar ( mean vector2, covariance matrix2 ) pt vector2 {
	/* Cholesky decomp covariance matrix */
	A := Cholesky(covariance)
	/* make 2 random variates */
	randx, randy := rand.NormFloat64(), rand.NormFloat64
	pt.x = mean.x + A.mxx * randx + A.mxy * randy
	pt.y = mean.y + A.myy * randy + A.myx * randx
	return pt
}
